<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/include/includeHeader.jsp"%>
<%@ page import="java.util.*,
                 com.kylin.common.util.*,
                 com.kylin.common.paginate.DisplayPage,
                 com.kylin.common.dict.orm.Dict,
                 com.kylin.common.dict.orm.CatDict" %>
<%
	List datas= null;
	CatDict cat = null;
	Dict parent = null;
  if(request.getAttribute("CatDict") instanceof CatDict){
      cat = (CatDict)request.getAttribute("CatDict");
	 String doUrl = "/admin/dict/manageDict.do?catId=" + cat.getId();
  	  if(request.getAttribute("parent") instanceof Dict) 
          parent = (Dict)request.getAttribute("parent");
%>
	<br>  属性表     <b>[ <%=cat.getName() %> ] </b>
    <% if(parent != null) out.print("   "+parent.getName()+"  的二级项 "); %>
           的内容
	<hr/>
<mytag:MyActionMsg />
<script>
    function deleteOne(delUrl){
        if(confirm("确定要删除此条数据吗？") ){
            location.href = delUrl ;
        }
    }
</script>	
<table class='pageTable' cellspacing='0' cellpadding='0'> 
     <tr>
        <td class='pageTitle'> </td>
        <td class='pageTitle'>排序号</td>
        <td class='pageTitle'>名称</td>
        <td class='pageTitle'>语言种类</td>
        <td class='pageTitle'>描述</td>
        <td class='pageTitle'>操作</td>
<%
        if(CatDict.IS_HAS_SUB.equals(cat.getHassub()) && parent==null){
			out.println("<td class='pageTitle'>查看子项</td>");
        }
%>        
      </tr>
<%      
  if(request.getAttribute(Constants.KEY_REQUEST_RESULT   )!=null){
     DisplayPage dispage = (DisplayPage)request.getAttribute(Constants.KEY_REQUEST_RESULT);
     String searchUrl   = doUrl + "&CMD=search";
     String bfUpdateUrl = doUrl + "&CMD=bfUpdate&page="+dispage.getPageNumber() + "&searchId="+dispage.getSearchId();
     String deleteUrl   = doUrl + "&CMD=delete&page="+dispage.getPageNumber() + "&searchId="+dispage.getSearchId();
     deleteUrl += dispage.getPageNumber();
     if(parent != null){
         searchUrl += "&parent="+parent.getId();
         deleteUrl += "&parent="+parent.getId();
     }
     datas= dispage.getList();
     if(datas != null || datas.size() > 0){
     	for(int i=0;i<datas.size();i++){
         	Dict dict = (Dict)datas.get(i);
%>
    <tr class='row<%=(i%2)%>'> 
       <td class='pageTd'><%=(i+1)%>(<%=dict.getId()%>)</td> 
       <td class='pageTd'><%=dict.getOrdering()%>  </td> 
       <td class='pageTd'><%=dict.getName()%>      </td> 
       <td class='pageTd'><% try{out.println(UTool.getLanguageName(dict.getLanguage(),Locale.getDefault()) ); }catch(Exception e){}%>  </td> 
       <td class='pageTd'><%=JspHelper.checkNull(dict.getDescription())%>&nbsp;</td> 
       <td class='pageTd'>
            <a href="<%=bfUpdateUrl+"&id="+dict.getId()%>">编辑</a>/
            <a href="#" onclick="deleteOne('<%=deleteUrl+"&id="+dict.getId()%>')" >删除</a>
       </td> 
<%
        if( CatDict.IS_HAS_SUB.equals(cat.getHassub()) && parent==null ){
			out.println("<td class='pageTd'><a href='" + searchUrl 
			          + "&parent="+dict.getId()+ "'>二级属性</a></td>");
        }
%>   
    </tr> 
<%
     	}
        out.println("</table>");
        out.println(JspHelper.getPageBar(dispage,searchUrl));
     }
    }
%>
<br/>

<!--   增加新项  -->
<html:form action="/admin/dict/manageDict.do">
<input type="hidden" name="CMD" value="add">
<input type="hidden" name="catId" value="<%=cat.getId() %>">
<table >

    <tr class='row1'> 
      <td>语言种类&nbsp; </td>
      <td>
      <%
          String currLang = request.getParameter("language");
          if(currLang == null)
              currLang = sessionLocale.toString();
      %>
		 <mytag:national name="language" notEmpty="true" 
		 	value="<%=currLang%>" dictName="<%=Constants.SYSLANGUAGE%>" />                 
      </td>
     </tr>
      <tr class='row2'>
      <td>排序号  &nbsp;</td>
      <td >
          <input type="text" name="ordering" value="100">
      </td>
      </tr>
     <tr class='row2'>
      <td>选项名称&nbsp; </td>
      <td >
          <input type="text" name="name">
          <script>document.dictForm.name.focus();</script>
      </td>
      </tr>
     <tr class='row1'>
      <td>描述&nbsp; </td>
      <td >
          <textarea  name="description"></textarea>
      </td>
      </tr>
      <tr class='row1'>
      <td> </td>
      <td class='pageTd'>
          <input type="submit" value="增加">
      </td>
    </tr>
</table>
<% 
	if(parent != null ){ 
%>
       <input type='hidden' name='parent' value='<%=parent.getId()%>'>
      <br> <input type="button" value="返回 [<%=cat.getName() %>]" 
      onclick="location.replace('<%=doUrl + "&CMD=search" %>')">
<%
	}
%>
</html:form>
<%    
  }  
%>
 

